Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.5K
Views
React Native - Expo media library [Could not create asset.]

I am generating pdf file with expo-print library, after that I want to save it to gallery or download it to gallery without creating any extra album in user's device.

Below is the code for my Invoice App:

import { shareAsync } from "expo-sharing";
import * as MediaLibrary from 'expo-media-library';
import * as Print from 'expo-print';

const printToPdf = async () => {

    let html = PdfCode(company, customer, products); // PDF code is working
    try {

      const { uri } = await Print.printToFileAsync({ html })
      //Taking device permission
      const perms = await MediaLibrary.requestPermissionsAsync();
      if (perms.granted) {
        await MediaLibrary.saveToLibraryAsync(uri); // <- ERROR here, code stops here and break
        console.log("Saved to media library"); // <- Not printed in console.
      }
      await shareAsync(uri, { UTI: '.pdf', mimeType: 'application/pdf' });
    } catch (error) {
      console.log(error);
    }
  }

I have marked a comment where I am getting the issue in the code. I have tried MediaLibrary.createAssestSync() but I am getting same error, the full error log is mentioned below: Error:

Could not create asset.
at node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:104:50 in promiseMethodWrapper
at node_modules\expo-modules-core\build\NativeModulesProxy.native.js:27:27 in moduleName.methodInfo.name
at node_modules\expo-media-library\build\MediaLibrary.js:168:17 in saveToLibraryAsync
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:66:31 in <anonymous>
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:124:27 in invoke
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:148:16 in PromiseImpl$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:45:6 in tryCallTwo
at node_modules\react-native\node_modules\promise\setimmediate\core.js:200:22 in doResolve
at node_modules\react-native\node_modules\promise\setimmediate\core.js:66:11 in Promise
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:147:15 in callInvokeWithMethodAndArg
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:152:154 in _invoke
at node_modules\@babel\runtime\helpers\regeneratorRuntime.js:238:57 in exports.async
at node_modules\expo-media-library\build\MediaLibrary.js:164:7 in saveToLibraryAsync
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!